<?
/**
 * Template for constants file edit utilite
 *
 * Project: LanguageTranslation<br/>
 * File: index.tpl.php
 *
 * @author Quality Solutions
 * @package templates
 */
?>
<?includeTemplate(PATH_TEMPLATES_INC.'/header.tpl.php', array(
    'sPageTitle' => 'Language Translators',
));?>

<? if (!empty($aListFile)):?>
	<?if (isset($_SESSION["iMessage"])):?>
		<div class="Message">
			<?if ($_SESSION["iMessage"] == MESSAGE_SAVED_SUCCESSFULLY):?>
				<?  echo LA_ADMIN_LANG_SAVED ?>
			<?endif;?>
			<?if ($_SESSION["iMessage"] == MESSAGE_CREATED_FILE):?>
				<?  echo LA_ADMIN_LANG_FILESAVED ?>
			<?endif;?>
			<?if ($_SESSION["iMessage"] == MESSAGE_RELOADED_FILE):?> Language file has been reloaded successfully <?endif;?> 
		</div>
	<?endif;?>
	<table width="100%"><tr><td valign="top">
	<form action="" method="post" name="currentFile">
		<b><? echo LA_ADMIN_LANG_FILE; ?>:</b>&nbsp;&nbsp;
		<select name="filename" onchange="document.forms['currentFile'].submit();">
			<?foreach ($aListFile as $key => $value):?>
				<option value="<?=$value?>" <?if ($sCurFileName == $value) { echo "selected";}?>><?=$value?></option>
			<?endforeach;?>
		</select>
	</form>
	</td><td valign="top" align="right">
		<form action="<?=Http::removeUrlParameter($sCurrentUrl, 'page')?>" method="post">
	<input type="hidden" name="filename" value="<?=$sCurFileName?>" />
		<input type="text" name="filter" value="<?=$sFilter?>" />
		<input type="submit" value="<? echo LA_ADMIN_LANG_SEARCH ?>">	
	<?if(isset($sFilter)):?>
	<input type="button" value="Reset" onclick="window.location = '<?=htmlspecialchars(Http::removeUrlParameter(Http::removeUrlParameter($sCurrentUrl, 'filter'), 'page'))?>'" />
		<?endif;?>
	</form>
	</td></tr></table>
	<form action="<?=$sCurrentUrl?>" method="post" name="FileUser">
		<input type="hidden" name="act" value="" />
		<table border="1">
		<tr>
			<th><? echo LA_ADMIN_LANG_CONSTANT ?></th>
			<th><? echo LA_ADMIN_LANG_DEFAULT ?></th>
			<th><? echo LA_ADMIN_LANG_CUSTOM ?></th>
		</tr>
		<?foreach ($aResultArray as $value):?>
		<tr>
			<td width="20%"><?=$value[0]?></td>
			<td width="30%"><?echo ereg_replace("\\\'","'",htmlspecialchars($value[1]));?></td>
			<td width="50%">
				<textarea name="constant[<?=$value[0]?>]" cols="40"><?echo ereg_replace("\\\'","'",htmlspecialchars($value[2]));?></textarea>
			</td>
		</tr>
		<?endforeach;?>
		<tr>
			<td align="center" colspan="3">
				<input type="button" value="<? echo LA_ADMIN_LANG_SAVE ?>" onclick="submitForm('FileUser', 'Save');" />
				<input type="button" value="<? echo LA_ADMIN_LANG_GENERATE ?>" onclick="submitForm('FileUser', 'GenerateFile');" />
				<input type="button" value="<? echo LA_ADMIN_LANG_RELOAD ?>" onclick="submitForm('FileUser', 'Reload');" /> 
				</td>
		</tr>
		</table>
	</form>

	<?includeTemplate(PATH_TEMPLATES_INC.'/pager.tpl.php', array(
		'iPageCount'   => $iPageCount,
		'iCurrentPage' => $iCurrentPage,
		'sCurrentUrl'  => $sCurrentUrl
		));
		?><center>
			<p><br (><form action="" method="post">
		<input type="hidden" name="act" value="AddConstant" />
		<input type="text" name="constant_name" />
		<input type="hidden" name="filename" value="<?=$sCurFileName?>" />
		<input type="submit" value="<? echo LA_ADMIN_LANG_ADD_NEW; ?>" />
	</form></p></center>
		
<?else:?>
	<br />
	<center>No language files</center>
<?endif;?>

<? includeTemplate(PATH_TEMPLATES_INC.'/footer.tpl.php'); ?>